Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: VE.Direct refactor issues from #505 #516

Merged
merged 2 commits into from
Oct 23, 2023

Conversation

schlimmchen
Copy link
Member

The refactor in #505 was not tested with VE.Direct turned off. Sorry for that.

If VE.Direct is turned off, the web API implementation still adds totals of the MPPT to be displayed by the web app on the top. It used VictronMppt.getData(), which did print an error message on the console, but did not return the proper fallback data structure. It returned a std::shared_ptr pointing to nullptr rather than one pointing to a default-initialized MPPT data struct, which was my intention.

The fix is simple, see the first commit. However, the error message is still printed on the console, since the web API implementation adds the totals unconditionally. Adding them only if VE.Direct is enabled is not working out, since those values are defined to be part of the respective typescript type definition, so the web app crashes if those values are missing. Also, they would only add the values of the first MPPT controller. In the future, these totals should be the respective sum over all MPPT controller of these totals. Hence the second commit implements the respective methods. Using them instead of VictronMppt.getData() also gets rid of the error message in the log in case VE.Direct is disabled.

All other uses of VictronMppt.getData() are now safe, as was originally intended. However, (manual) access to api/vedirectlivedata/status will still print the aforementioned error message to the log. Changing this is not really possible (without further refactoring of the web app). The API endpoint should not respond with default-initialized values if the data is invalid or VE.Direct is not enabled. However, this was previously the case and will be the case now as well. This should be fixed once the liveview adds support for multiple MPPT charge controllers: The API endpoint will return a list of MPPT charge controller values, which will be empty if VE.Direct is disabled or the data is invalid.

Note that the aforementioned error message will not appear when accessing the live view, as the web app will not connect to the VE.Direct live view API endpoint if VE.Direct is disabled.

the changed return statement was supposed to return a shared_ptr to a
new and valid MPPT data struct as a fallback. however, it did return a
new shared_ptr that was initialized to nullptr.
this change makes the call to VictronMppt.getData() obsolete, which in
turn will therefore not cause an error message on the console if
VE.Direct (MPPT) is not enabled. this change also takes care that once
multiple VE.Direct MPPT charge controllers are supported, the sums of
the respective total values are used in the web app totals.
@helgeerbe helgeerbe merged commit 0fa2745 into hoylabs:development Oct 23, 2023
8 checks passed
@schlimmchen schlimmchen deleted the fixup-505-vedirect branch October 23, 2023 18:11
Copy link

github-actions bot commented Apr 4, 2024

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new discussion or issue for related concerns.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants